/*
    This file is part of the Time-of-Flight Tracer program. It is not part of
    the original PBRT source distribution. See the included license file for
    more information.

    Copyright(c) 2014 Microsoft Corporation

    Author: Phil Pitts
*/

#if defined(_MSC_VER)
#pragma once
#endif

#ifndef PBRT_INTEGRATORS_TOFPATH_H
#define PBRT_INTEGRATORS_TOFPATH_H

#include "pbrt.h"
#include "integrator.h"
#include "integrators/path.h"


struct ToFPathVertex : public PathVertex {
	float pathlength;
};


class ToFPathIntegrator : public PathIntegrator {
public:
	ToFPathIntegrator(int md, float lambdaMin, float lambdaMax);

	IntegrationResult Li(const Scene *scene, const Renderer *renderer,
        const RayDifferential &ray, const Intersection &isect,
        const Sample *sample, RNG &rng, MemoryArena &arena) const;

protected:
	uint32_t GeneratePath(PathData &data, const RayDifferential r,
		const Intersection &firstIsect, const Sample* sample, ToFPathVertex *path,
		RayDifferential *escapedRay, Spectrum *escapedAlpha) const;
	void SaveToFVertexInfo(ToFPathVertex *v, int pathIdx, 
		const RayDifferential &ray) const;
	Spectrum DirectLightingVertex(PathData &data, const Sample *sample,
		int pathIdx, const ToFPathVertex &v, float *light2isect) const;

	float lambdaMin, lambdaMax;
};


ToFPathIntegrator *CreateToFPathSurfaceIntegrator(const ParamSet &params);

#endif // PBRT_INTEGRATORS_TOFPATH_H
